---
swagger: '2.0'
info:
  version: 1.0.0
  title: GeoServer Importer Extension - Transforms
  description: The Importer extension gives a GeoServer administrator an alternate, more-streamlined method for uploading and configuring new layers. The transforms endpoint manages data transforms applied to individual import jobs. The importer extension is an optional install and may not be available on all deployments of GeoServer
  contact:
    name: GeoServer
    email: 'geoserver-users@sourceforge.net'
    url: 'http://geoserver.org/comm/'
host: localhost:8080
basePath: /geoserver/rest

paths:
  /imports/{importId}/tasks/{taskId}/transforms:
    get:
      operationId: getTransforms
      tags:
       - "ImporterTransforms"
      summary: Retrieve transformation list
      description: Retrieve the list of transformations of a task with id {taskId} within import with id {importId}
      produces:
        - application/json
        - text/html
      parameters:
        - $ref: "#/parameters/ImportId"
        - $ref: "#/parameters/TaskId"
        - $ref: "#/parameters/ExpandParameter"
      responses:
        200:
          description: OK
          schema:
            $ref: "#/definitions/Transforms"
          examples:
            application/json: |
              {
                "transforms": [
                  {
                    "type": "ReprojectTransform",
                    "href": "http://localhost:8080/geoserver/rest/imports/0/tasks/1/transforms/0",
                    "source": null,
                    "target": "EPSG:4326"
                  },
                  {
                    "type": "DateFormatTransform",
                    "href": "http://localhost:8080/geoserver/rest/imports/0/tasks/1/transforms/1",
                    "field": "date",
                    "format": "yyyyMMdd"
                  }
                ]
              }
    post:
      operationId: postTransform
      tags:
       - "ImporterTransforms"
      summary: Create a new transformation
      description: Create a new transformation and append it inside a task with id {taskId} within import with id {importId}
      consumes:
        - application/json
        - text/json
      parameters:
        - $ref: "#/parameters/ImportId"
        - $ref: "#/parameters/TaskId"
        - $ref: "#/parameters/ExpandParameter"
        - $ref: "#/parameters/TransformParameter"
      responses:
        201:
          description: Created
          headers:
            Location:
              description: href to the newly created transform
              type: string
  /imports/{importId}/tasks/{taskId}/transforms/{transformId}:
    get:
      operationId: getTransform
      tags:
       - "ImporterTransforms"
      summary: Retrieve a transformation
      description: Retrieve a transformation identified by {transformId} inside a task with id {taskId} within import with id {importId}
      produces:
        - application/json
        - text/html
      parameters:
        - $ref: "#/parameters/ImportId"
        - $ref: "#/parameters/TaskId"
        - $ref: "#/parameters/TransformId"
        - $ref: "#/parameters/ExpandParameter"
      responses:
        200:
          description: OK
          schema:
            $ref: "#/definitions/Transform"
    put:
      operationId: putTransform
      tags:
       - "ImporterTransforms"
      summary: Modifies a transformation
      description: Modifies the definition of a transformation identified by {transformId} inside a task with id {taskId} within import with id {importId}
      consumes:
        - application/json
        - text/json
      produces:
        - application/json
        - text/html
      parameters:
        - $ref: "#/parameters/ImportId"
        - $ref: "#/parameters/TaskId"
        - $ref: "#/parameters/TransformId"
        - $ref: "#/parameters/ExpandParameter"
        - $ref: "#/parameters/TransformParameter"
      responses:
        200:
          description: OK
          schema:
            $ref: "#/definitions/Transform"
    delete:
      operationId: deleteTransform
      tags:
       - "ImporterTransforms"
      summary: Removes the transformation 
      description: Removes the transformation identified by {transformId} inside a task with id {taskId} within import with id {importId}
      parameters:
        - $ref: "#/parameters/ImportId"
        - $ref: "#/parameters/TaskId"
        - $ref: "#/parameters/TransformId"
      responses:
        200:
          description: OK

parameters:
  ExpandParameter:
    name: expand
    type: string
    in: query
    description: 'What level to expand the response object to. Can be "self" (expand only the response object and its immediate children), "all" (expand all children), "none" (don''t include any children), or a nonnegative integer, indicating the depth of children to expand to. Defaults to "self" or "none", depending on the request.'
    required: false
  TransformParameter:
    name: transformBody
    description: The transform to add.
    in: body
    required: true
    schema:
      $ref: "#/definitions/Transform"
  ImportId:
    name: importId
    in: path
    description: The ID of the import
    required: true
    type: string
  TaskId:
    name: taskId
    in: path
    description: The ID of the task
    required: true
    type: string
  TransformId:
    name: transformId
    in: path
    description: The ID of the transform
    required: true
    type: string 
    
definitions:      
  Transforms:
    title: transforms
    type: array
    description: A list of transforms
    items:
      $ref: "#/definitions/Transform"
  Transform:
    title: transform
    type: object
    description: A data transform applied to the import data.
    properties:
      type:
        type: string
        description: The name of the transform
      href: 
        type: string
        description: URL to the transform endpoint
